package o;

import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.SeekBar;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import o.ah.g;

public class cd extends cg {
    private boolean ˊ = false;
    private ColorStateList ˋ = null;
    private final SeekBar ˎ;
    private Mode ˏ = null;
    private Drawable ॱ;
    private boolean ॱॱ = false;

    public cd(SeekBar seekBar) {
        super(seekBar);
        this.ˎ = seekBar;
    }

    public void ˎ(AttributeSet attributeSet, int i) {
        super.ˎ(attributeSet, i);
        cw ॱ = cw.ॱ(this.ˎ.getContext(), attributeSet, g.ʼˋ, i, 0);
        Drawable ˎ = ॱ.ˎ(g.ʻˋ);
        if (ˎ != null) {
            this.ˎ.setThumb(ˎ);
        }
        ॱ(ॱ.ˋ(g.ʼˊ));
        if (ॱ.ᐝ(g.ʽᐝ)) {
            this.ˏ = cl.ˏ(ॱ.ॱ(g.ʽᐝ, -1), this.ˏ);
            this.ॱॱ = true;
        }
        if (ॱ.ᐝ(g.ʻᐝ)) {
            this.ˋ = ॱ.ॱ(g.ʻᐝ);
            this.ˊ = true;
        }
        ॱ.ॱ();
        ˋ();
    }

    void ॱ(@Nullable Drawable drawable) {
        if (this.ॱ != null) {
            this.ॱ.setCallback(null);
        }
        this.ॱ = drawable;
        if (drawable != null) {
            drawable.setCallback(this.ˎ);
            gg.ˏ(drawable, ViewCompat.ʼ(this.ˎ));
            if (drawable.isStateful()) {
                drawable.setState(this.ˎ.getDrawableState());
            }
            ˋ();
        }
        this.ˎ.invalidate();
    }

    private void ˋ() {
        if (this.ॱ == null) {
            return;
        }
        if (this.ˊ || this.ॱॱ) {
            this.ॱ = gg.ʻ(this.ॱ.mutate());
            if (this.ˊ) {
                gg.ॱ(this.ॱ, this.ˋ);
            }
            if (this.ॱॱ) {
                gg.ˋ(this.ॱ, this.ˏ);
            }
            if (this.ॱ.isStateful()) {
                this.ॱ.setState(this.ˎ.getDrawableState());
            }
        }
    }

    public void ˊ() {
        if (this.ॱ != null) {
            this.ॱ.jumpToCurrentState();
        }
    }

    public void ˎ() {
        Drawable drawable = this.ॱ;
        if (drawable != null && drawable.isStateful() && drawable.setState(this.ˎ.getDrawableState())) {
            this.ˎ.invalidateDrawable(drawable);
        }
    }

    public void ˊ(Canvas canvas) {
        int i = 1;
        if (this.ॱ != null) {
            int max = this.ˎ.getMax();
            if (max > 1) {
                int intrinsicWidth = this.ॱ.getIntrinsicWidth();
                int intrinsicHeight = this.ॱ.getIntrinsicHeight();
                intrinsicWidth = intrinsicWidth >= 0 ? intrinsicWidth / 2 : 1;
                if (intrinsicHeight >= 0) {
                    i = intrinsicHeight / 2;
                }
                this.ॱ.setBounds(-intrinsicWidth, -i, intrinsicWidth, i);
                float width = ((float) ((this.ˎ.getWidth() - this.ˎ.getPaddingLeft()) - this.ˎ.getPaddingRight())) / ((float) max);
                intrinsicHeight = canvas.save();
                canvas.translate((float) this.ˎ.getPaddingLeft(), (float) (this.ˎ.getHeight() / 2));
                for (i = 0; i <= max; i++) {
                    this.ॱ.draw(canvas);
                    canvas.translate(width, 0.0f);
                }
                canvas.restoreToCount(intrinsicHeight);
            }
        }
    }
}
